package list

type arrayStack struct {
	list []interface{}
}

func NewArrayStack() *arrayStack {
	return &arrayStack{make([]interface{}, 0, 10)}
	//return &arrayStack{[]interface{}{}}
}

func (this *arrayStack) Push(e interface{}) {
	this.list = append(this.list, e)
}

func (this *arrayStack) Pop() interface{} {
	c := len(this.list)
	if c == 0 {
		return nil
	}

	e := this.list[c-1]
	this.list = this.list[:c-1]
	return e
}

func (this *arrayStack) Peek() interface{} {
	c := len(this.list)
	if c == 0 {
		return nil
	}

	return this.list[c-1]
}

func (this *arrayStack) Capacity() int {
	return cap(this.list)
}

func (this *arrayStack) Size() int {
	return len(this.list)
}
